<?php
/**
 * Formulário padrão para tela de pesquisa
 */
class App_Form_Representante extends Voitech_Form
{
	public function _construct($options=array())
	{
		parent::__construct($options);
		
		$this->setAttribs(array('name'=>'frmCadastroRepresentante', 'id'=>'frmCadastroRepresentante'));
		$this->setAction('/fornecedor/salvar-representante');
		$this->setMethod('post');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_pessoa' );
		$noPessoa->setLabel( 'Nome:' );
		$noPessoa->setAttribs( array('size'=>'55') );
		$noPessoa->addFilter( new Zend_Filter_StringTrim() );
		$noPessoa->addValidator( new Zend_Validate_StringLength( array( 'min'=>'4', 'max'=>'155' ) ) );
		$noPessoa->setDecorators( $this->_decoratorDefault );
		$noPessoa->setRequired( true );
		$this->addElement( $noPessoa );	
		
		$nuCpf = new Zend_Form_Element_Text( 'nu_cpf' );
		$nuCpf->setLabel( 'Cpf:' );
		$nuCpf->setAttribs( array( 'size'=>'15', 'maxlength'=>'11' ) );
		$nuCpf->addFilter( new Zend_Filter_StringTrim() );
		$nuCpf->addValidator( new Zend_Validate_StringLength( array( 'min'=>'11', 'max'=>'11' ) ) );
		$nuCpf->addValidator( new Voitech_Validate_Cpf() );
		$nuCpf->setDecorators( $this->_decoratorDefault );
		$nuCpf->setRequired( true );
		$this->addElement( $nuCpf );
		
		$nuCpf = new Zend_Form_Element_Text( 'nu_rg' );
		$nuCpf->setLabel( 'Rg:' );
		$nuCpf->setAttribs( array( 'size'=>'15', 'maxlength'=>'20' ) );
		$nuCpf->addFilter( new Zend_Filter_StringTrim() );
		$nuCpf->addValidator( new Zend_Validate_StringLength( array( 'min'=>'0', 'max'=>'20' ) ) );
		$nuCpf->setDecorators( $this->_decoratorDefault );		
		$this->addElement( $nuCpf );		

		$buttonCdst = new Zend_Form_Element_Submit('Salvar');
		$buttonCdst->setAttribs( array('class'=> 'first-child last-child','style'=>'float:right; margin-top: 17px', 'id' => 'btnSalvar' ) );
		$buttonCdst->setDecorators( $this->_decoratorDefault );
		$buttonCdst->removeDecorator( 'label' );
		
		$this->addElement( $buttonCdst );
		$this->removeDecorator('label');
		
		$this->addDisplayGroup(array('nu_cpf','no_pessoa','nu_rg', 'Salvar'),'Cadastro',array('legend' => 'Formulario de cadastro de pessoa', 'class'=>'legenda'));
	}
}